{template 'common/header'}
<title>{if $trade && $trade['withdraw']==1}余额明细{else}充值记录{/if}</title>
<style>
	.credit_tab {height:30px; margin:5px; border:1px solid #ff6801; border-radius:5px; overflow:hidden;font-size:13px;background:#fff;padding-right: -2px;}
	.credit_nav {height:30px; width:50%;  background:#fff; color:#666; text-align:center; line-height:30px; float:left;}
	.credit_navon {color:#fff; background:#ff6801;}
	.credit_no {height:100px; width:100%; margin:50px 0px 60px; color:#ccc; font-size:12px; text-align:center;}
	#credit_loading { padding:10px;color:#666;text-align: center;}
</style>
<div class="mui-content content-bg-w7">
	<header class="mui-bar mui-bar-nav">
		<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left header-back-icon"></a>
		<h1 class="mui-title">{if $trade && $trade['withdraw']==1}余额明细{else}充值记录{/if}</h1>
	</header>
	{if $trade && $trade['withdraw']==1}
	<div class="credit_tab">
		<div class="credit_nav {if $_GPC['type']==0}credit_navon{/if}" data-type='0' >充值记录</div>
		<div class="credit_nav {if $_GPC['type']==1}credit_navon{/if}"  data-type='1'>提现记录</div>
	</div>
	{/if}
	<div id='container'></div>
</div>
<script id='tpl_log' type='text/html'>
	<div class="list-recharge-record">
		<ul class="list-group-recharge-record">
			<%each list as log%>
			<li class="list-item-recharge-record">
				<div class="info-recharge-record">
					<span class="info-recharge-num">
						<%if log.type==0%>充值金额: <%/if%>
                		<%if log.type==1%>提现金额: <%/if%>
                		<%if log.type==2%>佣金打款: <%/if%>
                		<%log.money%> 元
					</span>
					<span class="info-recharge-time">
						<%log.createtime%>
					</span>
				</div>
				<%if log.status==0%>
					<div class="info-recharge-state state-succes"><%if log.type==0%>未充值<%else%>申请中<%/if%></div>
				<%/if%>
				<%if log.status==1%>
					<div class="info-recharge-state state-succes">
						<%if log.type==0%>充值成功<%/if%>
						<%if log.type==1%>提现成功<%/if%>
						<%if log.type==2%>打款成功<%/if%>
            		</div>
				<%/if%>
				<%if log.status==-1%>
					<div class="info-recharge-state state-succes"><%if log.type==1%>提现失败<%/if%></div>
				<%/if%>
				<%if log.status==3%>
					<div class="info-recharge-state state-succes"><%if log.type==0%>充值退款<%/if%></div>
				<%/if%>
			</li>
			<%/each%>
		</ul>
	</div>
	<div class="placeholder-box"></div>
</script>
<script id='tpl_empty' type='text/html'>
	<div class="credit_no"><i class="fa fa-file-text-o" style="font-size:100px;"></i><br><span style="line-height:18px; font-size:16px;">您还没有相关分销团队成员~</span></div>
</script>
<script language="javascript">
	var page = 1;
	var scrolled = false;
	var current_type = "{php echo intval($_GPC['type'])}";
	require(['tpl', 'core'], function (tpl, core) {

		function bindScroller() {
			var loaded = false;
			var stop = true;

			$(window).scroll(function () {
				if (loaded) {
					return;
				}
				totalheight = parseFloat($(window).height()) + parseFloat($(window).scrollTop());
				if ($(document).height() <= totalheight) {

					if (stop == true) {
						stop = false;
						scrolled = true;
						$('#container').append('<div id="credit_loading"><i class="fa fa-spinner fa-spin"></i> 正在加载...</div>');
						page++;
						core.json('member/log', {type: current_type, page: page}, function (json) {
							stop = true;
							$('#credit_loading').remove();
							$("#container").append(tpl('tpl_log', morejson.result));
							if (morejson.result.list.length < morejson.result.pagesize) {
								$("#container").append('<div id="credit_loading">已经加载完全部记录</div>');
								loaded = true;
								$(window).scroll = null;
								return;
							}
						}, true);
					}
				}
			});
		}

		function getLog(type) {
			$('.credit_nav').removeClass('credit_navon');
			$('.credit_nav[data-type=' + type + ']').addClass('credit_navon');
			core.json('member/log', {type: type, page: page}, function (json) {
				if (json.result.list.length <= 0) {
					$('#container').html(tpl('tpl_empty'));
					return;
				}
				$('#container').html(tpl('tpl_log', json.result));
				bindScroller();
			}, true);
		}

		$('.credit_nav').unbind('click').click(function () {
			page = 1;
			current_type = $(this).data('type')
			getLog(current_type);

		});
		getLog(current_type);
	})
</script>
{php $show_footer=true}
{template 'common/footer'}